/**
 * Created by mac on 16/7/14.
 */
var webpack = require('webpack');
var path = require('path');
var moduleName = "test";

var ROOT_PATH = path.resolve(__dirname);
var ENTRY_PATH = path.resolve(ROOT_PATH,'./src/'+moduleName);  //输入路劲
var BULID_PATH = path.resolve(ROOT_PATH,'./static/'+moduleName); //输出路劲

module.exports = {
    //页面入口文件配置
    entry: {
        /*index: [
            'webpack-dev-server/client?http://localhost:5000',
            'webpack/hot/only-dev-server',
            '.src/'+moduleName+'/index.js'
        ]*/
        index:path.resolve(ENTRY_PATH,'index.js')
    },
    //入口文件输出配置
    output: {
        path: BULID_PATH,
        filename: 'bundle.js'
    },
    module: {
        //加载器配置
        rules: [
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader'
            },
            {
                test: /\.(png|jpg)$/,
                loader: 'url-loader?limit=8192'
            },
            /*{
                two-way1: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            },*/
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/,
                /*query: {
                    presets: ['es2015','react','stage-0']
                }*/
            },
        ]
    },
    externals: {
        /** require('XXX') : window.XXX **/
        "react": 'React',
        "react-dom": "ReactDOM",
        'react/lib/update': 'React.addons.update',
        'react/lib/ReactCSSTransitionGroup': 'React.addons.CSSTransitionGroup'

    },
    //其它解决方案配置
    resolve: {
        extensions: ['.js', '.json', '.scss']
    },
    //插件项
    plugins: [
        // new webpack.HotModuleReplacementPlugin(),
        // new webpack.NoErrorsPlugin()
    ]
};